-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix invalid suppression in System.Attribute #70710
Conversation
The suppression on System.Attribute is wrong. Ran into this in dotnet#70201 where `EditorBrowsableAttributeTests.EqualsTest` is failing because we didn't generate any reflection metadata for the field. There's a difference between "a field is kept" and "a field is accessible from reflection without issues". The issue is more pronounced in Native AOT (where the field can be completely erased from reflection). The implementation of Attribute.Equals didn't see any fields on the attribute type because the static analysis didn't deem any of them necessary. This fixes the suppression and replaces it with a more correct DAM on type.
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @sbomer, @joperezr Issue DetailsThe suppression on There's a difference between "a field is kept" and "a field is accessible from reflection without issues". The issue is more pronounced in Native AOT (where the field can be completely erased from reflection). The implementation of Fields (or methods) that are provably not visible from reflection without warnings are free to be optimized in any way by trimming (e.g. how we strip method parameter names in illink). This fixes the suppression and replaces it with a more correct DAM on type. Cc @dotnet/ilc-contrib
|
Oh, right, okay. I didn't want to open that can of worms. I think I'm just going to special case System.Attribute descendants in the compiler to compensate for the invalid suppression here. |
The suppression on
System.Attribute
is wrong. Ran into this in #70201 whereEditorBrowsableAttributeTests.EqualsTest
is failing because we didn't generate any reflection metadata for the field. This proves beyond any doubt that even I can't write a correct trim warning suppression.There's a difference between "a field is kept" and "a field is accessible from reflection without issues". The issue is more pronounced in Native AOT (where the field can be completely erased from reflection). The implementation of
Attribute.Equals
didn't see any fields on the attribute type because the static analysis didn't deem any of them necessary.Fields (or methods) that are provably not visible from reflection without warnings are free to be optimized in any way by trimming (e.g. how we strip method parameter names in illink).
This fixes the suppression and replaces it with a more correct DAM on type.
Cc @dotnet/ilc-contrib